<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@taglib prefix="shiro" uri="http://shiro.apache.org/tags" %>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>账单列表</title>
    <link rel="stylesheet" type="text/css" href="/static/plugins/easyui/themes/material/easyui.css">
    <link rel="stylesheet" type="text/css" href="/static/plugins/easyui/themes/icon.css">
    <script type="text/javascript" src="/static/plugins/easyui/jquery.min.js"></script>
    <script type="text/javascript" src="/static/plugins/easyui/jquery.easyui.min.js"></script>
    <script type="text/javascript" src="/static/plugins/easyui/locale/easyui-lang-zh_CN.js"></script>
    <script>
        $(function () {

            $('#stockOutcomeBill_dg').datagrid({
                url: '/stockOut/query.do',
                fitColumns: true,
                fit: true,
                pagination: true,
                singleSelect: true,
                toolbar: "#stockOutcomeBill_tb",
                rownumbers: true,
                columns: [[
                    {field: 'id', title: 'ID', width: 100},
                    {field: 'sn', title: '出库单编号', width: 100},
                    {field: 'vdate', title: '出库单日期', width: 100},
                    {field: 'totalAmount', title: '总金额', width: 100},
                    {field: 'totalNumber', title: '总数量', width: 100},
                    {field: 'auditTime', title: '审核时间', width: 100},
                    {field: 'inputTime', title: '录入时间', width: 100},
                    {
                        field: 'status', title: '状态', width: 100, formatter: function (value, row, index) {
                            if (value == 2) {
                                return "已审核";
                            } else {
                                return "<span style='color: red'>未审核</span>";
                            }
                        }
                    },
                    {
                        field: 'inputUser', title: '录入人', width: 100, formatter: function (value, row, index) {
                            if (value) {
                                return value.realname;
                            }
                        }
                    },
                    {
                        field: 'auditor', title: '审核人', width: 100, formatter: function (value, row, index) {
                            if (value) {
                                return value.realname;
                            }
                        }
                    },
                    {
                        field: 'outType', title: '出库类型', width: 100, formatter: function (value, row, index) {
                            if (value == 1) {
                                return "销售";
                            } else if (value == 2) {
                                return "礼物";
                            } else {
                                return "未知";
                            }
                        }
                    }

                ]]
            });
        })


        function audit() {
            var tr = $('#stockOutcomeBill_dg').datagrid("getSelected");
            if (!tr) {
                //没有选中
                $.messager.alert('温馨提示', "至少选中一条数据", "error");
                return;
            }



            $.messager.alert("温馨提示:","是否确定审核?","info",function () {
                $.get("/stockOut/audit.do", {id: tr.id}, function (data) {
                    if (data.success) {
                        $.messager.alert('温馨提示', '操作成功', 'info', function () {
                            $('#stockOutcomeBill_dg').datagrid("reload");
                        });
                    }
                    else {
                        $.messager.alert('温馨提示', data.msg, "error");
                    }
                })
            });
        }

        // 高级查询操作
        function searchForm() {
            // 获取关键字
            var beginDate = $("input[name='beginDate']").val();
            var endDate = $("input[name='endDate']").val();
            var status = $("input[name='status']").val();
            // 传人关键字刷新数据表格
            $("#stockOutcomeBill_dg").datagrid("load",{
                "beginDate":beginDate,
                "endDate":endDate,
                "status":status,
            });
        }

    </script>
</head>
<body>
<table id="stockOutcomeBill_dg"></table>
<div id="stockOutcomeBill_tb">
    <td>开始时间</td>
    <td><input name="beginDate" class="easyui-datebox" style="width: 130px"></td>
    <td>结束时间</td>
    <td><input name="endDate" class="easyui-datebox" style="width: 130px"></td>
    <input  name="status" class="easyui-combobox" data-options="
        panelHeight: 'auto',
		valueField: 'value',
		textField: 'label',
		data: [{
			label: '全部',
			value: '-1',
			'selected': true
		},{
			label: '未审核',
			value: '1'
		},{
			label: '已审核',
			value: '2'
		}]" />
    <a class="easyui-linkbutton" onclick="searchForm();" data-options="iconCls:'icon-search',text:'搜索',plain:true"></a>
    <a class="easyui-linkbutton" onclick="audit();" data-options="iconCls:'icon-edit',text:'审核',plain:true"></a>
</div>

</body>
</html>
